package cn.myzqu.springcloud.feignconsumer.controller;


import cn.myzqu.springcloud.feignconsumer.pojo.User;
import cn.myzqu.springcloud.feignconsumer.service.HelloService;
import cn.myzqu.springcloud.feignconsumer.service.RefactorHelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @Autowired
    private HelloService helloService;

    @Autowired
    private RefactorHelloService refactorHelloService;

    @RequestMapping("/feign-consumer")
    public String helloConsumer(){
        return helloService.hello();
    }


    @RequestMapping("/feign-consumer2")
    public String helloConsumer2(){
        StringBuilder str = new StringBuilder();
        str.append(helloService.hello()).append("\n");
        str.append(helloService.hello("郭秋景")).append("\n");
        str.append(helloService.hello(new User("qiuijing",18))).append("\n");
        str.append(helloService.hello("guoqiujing",23)).append("\n");
        return str.toString();
    }


    @RequestMapping("/feign-consumer3")
    public String helloConsumer3(){
        StringBuilder str = new StringBuilder();
        str.append(refactorHelloService.hello("郭秋景")).append("\n");
        str.append(refactorHelloService.hello(new cn.myzqu.springcloud.helloserviceapi.dto.User("qiuijing",18))).append("\n");
        str.append(refactorHelloService.hello("guoqiujing",23)).append("\n");
        return str.toString();
    }
}
